//
//  RW_MineViewModel.m
//  SleepApp
//
//  Created by MAC on 2021/3/22.
//  Copyright © 2021 RiceWang. All rights reserved.
//

#import "RW_MineViewModel.h"
#import "RW_HeaderCollectionViewCell.h"
#import "RW_ItemCollectionViewCell.h"

@implementation RW_MineViewModel
#pragma mark -- 功能逻辑
/** 新建用户歌单 */
-(void)addSUsersssSingleName:(NSString *)singleName
                  success:(void(^)(id response))success
                     fail:(void(^)(NSError *error))fail{
    
}

#pragma mark -- 视图模型获取
/** 获取用户header视图模型 */
-(void)getUserHeaderViewSuccess:(void(^)(NSArray<WLBaseCollectionViewLayerSection *> *response))success
                 fail:(void(^)(NSError *error))fail{
    if ([UserModel_WL isLogin]){
        [[[RW_UserModel getUserInfo] then:^id _Nullable(RW_UserModel * _Nullable value) {
            if (success){
                success([self getUserInfoSection:value]);
            }
            return nil;
        }] catch:^(NSError * _Nonnull error) {
            if (success){
                success([self getUserInfoSection:nil]);
            }
        }];
    } else {
        if (success){
            success([self getUserInfoSection:nil]);
        }
    }
}
/** 生成用户相关视图模型 */
-(NSArray<WLBaseCollectionViewLayerSection *> *)getUserInfoSection:(RW_UserModel *)userModel{
    NSMutableArray *array = [NSMutableArray array];
    
    WLBaseCollectionViewLayerSection *section = [[WLBaseCollectionViewLayerSection alloc]init];
    section.indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
    section.horizontalMaxWidth = Main_Screen_Width;
    
    CGSize itemSize = CGSizeZero;

    section.insetForSection = UIEdgeInsetsMake(5, 5, 0, 5);
    section.horizontalSection = 0;
    section.horizontalCount = 1;
    section.verticalSection = 0;
    
    itemSize = [section getCellSizeHeight:65];
  
    
    RW_HeaderCollectionViewCellModel *model = [[RW_HeaderCollectionViewCellModel alloc]init];
    model.user_model = userModel;
    
    [section.item addObject:[RW_HeaderCollectionViewCell getRow:model cellSize:itemSize]];
    [array addObject:section];
    return array;
}

/** 获取功能视图模型 */
-(void)getItemViewSuccess:(void(^)(NSArray<WLBaseCollectionViewLayerSection *> *response))success
                 fail:(void(^)(NSError *error))fail{
    if (success){
        success([self getItemSection]);
    }
}
/** 生成默认功能item */
-(NSArray<WLBaseCollectionViewLayerSection *> *)getItemSection{
    NSMutableArray *array = [NSMutableArray array];
    
    WLBaseCollectionViewLayerSection *section = [[WLBaseCollectionViewLayerSection alloc]init];
    section.indexPath = [NSIndexPath indexPathForRow:0 inSection:1];
    section.horizontalMaxWidth = Main_Screen_Width;
    section.insetForSection = UIEdgeInsetsMake(5, 5, 0, 5);
    section.horizontalSection = 0;
    section.horizontalCount = 1;
    section.verticalSection = 1;
    
    CGSize itemSize = [section getCellSizeHeight:40];
  
    
    {
        RW_ItemCollectionViewCellModel *model = [[RW_ItemCollectionViewCellModel alloc]init];
        model.item_type = Mine_Item_Type_PlayerClass;
        [section.item addObject:[RW_ItemCollectionViewCell getRow:model cellSize:itemSize]];
    }
    {
        RW_ItemCollectionViewCellModel *model = [[RW_ItemCollectionViewCellModel alloc]init];
        model.item_type = Mine_Item_Type_Feedback;
        [section.item addObject:[RW_ItemCollectionViewCell getRow:model cellSize:itemSize]];
    }
//    {
//        RW_ItemCollectionViewCellModel *model = [[RW_ItemCollectionViewCellModel alloc]init];
//        model.item_type = Mine_Item_Type_Statement;
//        [section.item addObject:[RW_ItemCollectionViewCell getRow:model cellSize:itemSize]];
//    }
    [array addObject:section];
    return array;
}


//Mine_Item_Type_Purchase,//内购商品列表
//Mine_Item_Type_Feedback,//意见反馈
//Mine_Item_Type_Statement,//内容声明
@end
